package luban;

import java.io.IOException;
import java.nio.file.Paths;

public class Cfg2 {

    public static cfg.Tables tables;

    public static void load() throws IOException {
        reload();
    }

    public static void reload() throws IOException {
        cfg.Tables tables = new cfg.Tables(Cfg2::createByteBufFromFile);
        Cfg2.tables = tables;
    }

    private static ByteBuf createByteBufFromFile(String file) throws IOException {
        return new ByteBuf(java.nio.file.Files.readAllBytes(
                Paths.get("../paradogs2-datatables-output", file + ".bytes")
                        .toAbsolutePath().normalize()
        ));
    }
}
